/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-05-06     liuchao       the first version
 */
#ifndef DRIVERS_INCLUDE_DRV_RELAY_H_
#define DRIVERS_INCLUDE_DRV_RELAY_H_
#include "board.h"

#define RELAY_PERIPH_PWR_PIN GET_PIN(E, 6)
#define RELAY_SAFE_PIN GET_PIN(F, 8)
//#define RELAY_LOCK_PIN GET_PIN(F, 2)
//#define RELAY_UNLOCK_PIN GET_PIN(F, 3)
#define RELAY_UNLOCK_PIN GET_PIN(F, 2)
#define RELAY_LOCK_PIN GET_PIN(F, 3)
#define RELAY_HYDRAULIC_PIN GET_PIN(F, 0)
#define RELAY_HY_START_PIN GET_PIN(F, 1)
#define RELAY_PUSH_PIN GET_PIN(C, 13)
#define RELAY_BACK_PIN GET_PIN(F, 7)

typedef enum
{
    RELAY_START = 0,
    // 外设电源
    RELAY_PERIPH_PWR = RELAY_START,
    // 安全限制
    RELAY_SAFE,
    // 自锁电机正转
    RELAY_LOCK,
    // 自锁电机反转
    RELAY_UNLOCK,
    // 液压站电源
    RELAY_HYDRAULIC,
    // 液压站启动
    RELAY_HY_START,
    // 推进电磁阀
    RELAY_PUSH,
    // 回退电磁阀
    RELAY_BACK,

    RELAY_END
} relay_e;

typedef enum
{
    RELAY_STATE_OFF, RELAY_STATE_ON, RELAY_STATE_END
} relay_state_e;

const char* relay_name(relay_e relay);
int relay_init(relay_e relay);
void relay_on(relay_e relay);
void relay_off(relay_e relay);
int relay_state(relay_e relay);
rt_base_t relay_pin(relay_e relay);

#endif /* DRIVERS_INCLUDE_DRV_RELAY_H_ */
